package cn.nawang.ebeim.test.constants;

import cn.nawang.ebeim.test.utils.SystemUtil;

import java.io.*;
import java.util.*;

public class Config {

    public static List<String> dsDirList = new ArrayList<String>();

    public static String DOWNLOAD_DIR ;

    public static String SERVER_HOST ;

    public static int SERVER_PORT ;

    public static String CONTAINER ;

    public static int CONCURRENT_NUM ;

    public static int RETRY_TIMES ;

    static {
        String confPath = SystemUtil.getConfPath() + "/config.properties";
        Properties prop = new Properties();
        try {
            InputStream inputStream = new FileInputStream(confPath);
            BufferedReader bf = new BufferedReader(new InputStreamReader(inputStream, "utf-8"));
            prop.load(bf);
        } catch (Exception e) {
            e.printStackTrace();
        }
        String dsDir = prop.getProperty("upload_dir");
        if (dsDir!=null && !"".equals(dsDir.trim())) {
            dsDirList.addAll(Arrays.asList(dsDir.split(",")));
        }
        DOWNLOAD_DIR = prop.getProperty("download_dir");
        SERVER_HOST = prop.getProperty("server_host");
        SERVER_PORT = Integer.parseInt(prop.getProperty("server_port"));
        CONTAINER = "ebeim-test-" + UUID.randomUUID().toString();

        CONCURRENT_NUM = Integer.parseInt(prop.getProperty("concurrent_num"));
        RETRY_TIMES = Integer.parseInt(prop.getProperty("retry_times"));
    }

}
